package com.roamer.controller;

import com.roamer.service.WeatherService;
import com.roamer.vo.WeatherVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author roamer
 * @version v1.0
 * @date 2020/3/26 12:50
 */
@Controller
@RequestMapping("weathers")
public class WeatherController {

    public final WeatherService weatherService;

    public WeatherController(WeatherService weatherService) {
        this.weatherService = weatherService;
    }

    @GetMapping("{city}")
    @ResponseBody
    public WeatherVO getCityWeather(@PathVariable("city") String city){
        return weatherService.getCityWeather(city);
    }
}
